<template>
  <div>
    <van-card
      v-for="(item, index) in searchList"
      :key="index"
      num="2"
      price="2.00"
      desc="描述信息"
      :title="item.title"
      :thumb="item.img"
    />
    <button @click="fanhui">返回</button>
  </div> 
</template>
<script>
export default {
  data() {
    return {
      list: [],
      //保存 的数据
      keywords: this.$route.query.value,
      //搜索 关键字
    };
  },
  mounted() {
    this.$axios.get("house.json").then((res) => {
      this.list = res.data.data;
    });
    //请求的数据
  },
  methods: {
    fanhui() {
      this.$router.push("/");
    },
  },
  computed: {
    searchList() {
      var newarr = this.list.filter((item) => {
        if (item.title.indexOf(this.keywords) != -1) {
          return item;
        }
      });
      return newarr;
    },
  },
  // 搜索关键字的数据
};
</script>
